<!-- @format -->
<script setup>
	import { onMounted, ref } from 'vue'
	import MyForm from './components/MyForm.vue'

	const formRef = ref(null)

	// onMounted(() => {
	// 	// console.log(formRef.value) // 获取 MyForm 组件实例
	// 	console.log(formRef.value.validate())
	// 	console.log(formRef.value.ccc)
	// })

	// 登录
	const onLogin = () => {
		// 做表单校验
		if (formRef.value.validate()) {
			console.log('ok')
		} else {
			console.log('不 ok')
		}
	}
</script>
<template>
	<div class="login-box">
		<MyForm ref="formRef" />
		<button @click="onLogin">登 录</button>
	</div>
</template>

<style scoped></style>
